from sqlalchemy import create_engine
import pymysql
import pandas as pd
# 创建一个mysql连接器，用户名是admin，密码Root123456!，端口为:3306
# engine = create_engine('mysql+pymysql://admin:Root123456!@192.168.18.76:3306/hrdata?charset=utf8')
# print(engine)

# 查看hrdata数据库中的数据表数目
# sqlalchemy版本问题报错
# formlist = pd.read_sql_query('show tables', con=engine)
# print('hrdata数据库数据表清单为：\n', formlist)
conn = pymysql.connect(host='192.168.18.76',
                       port=3306,
                       user='admin',
                       passwd='Root123456!',
                       db='hrdata',
                       charset='utf8')
# 会提示警告：pandas库只能支持SQLAlchemy的连接
formlist = pd.read_sql_query('show tables', con=conn)
print('hrdata数据库数据表清单为：\n', formlist)